#include <iostream>
#include <vector>
#include <queue>
using namespace std;

bool canFinish(int numCourses, vector<vector<int>>& prerequisites) {
    vector<int> indegree(numCourses, 0); 
    vector<vector<int>> graph(numCourses); 

    for (auto edge : prerequisites) {
        int course = edge[0];
        int prerequisite = edge[1];

        graph[prerequisite].push_back(course);
        indegree[course]++;
    }

    queue<int> q;

    for (int i = 0; i < numCourses; i++) {
        if (indegree[i] == 0) {
            q.push(i);
        }
    }

    int finishedCourses = 0;

    while (!q.empty()) {
        int course = q.front();
        q.pop();
        finishedCourses++;

        for (int neighbor : graph[course]) {
            indegree[neighbor]--;
            if (indegree[neighbor] == 0) {
                q.push(neighbor);
            }
        }
    }

    return finishedCourses == numCourses;
}

int main() {
    int numCourses = 4;
    vector<vector<int>> prerequisites = {{1, 0}, {2, 1}, {3, 2}, {0, 3}};

    if (canFinish(numCourses, prerequisites)) {
        cout << "可以完成课程" << endl;
    } else {
        cout << "无法完成课程" << endl;
    }

    return 0;
}